package com.zzyl.mapper;

import com.zzyl.dto.ResourceDto;
import com.zzyl.entity.Resource;
import com.zzyl.vo.MenuVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ResourceMapper {

    int deleteByPrimaryKey(Long id);

    int insert(Resource record);

    int insertSelective(Resource record);

    Resource selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Resource record);

    int updateByPrimaryKey(Resource record);

    /**
     * 这是Mybatis Generator拓展插件生成的方法(请勿删除).
     * This method corresponds to the database table sys_resource
     *
     * @mbg.generated
     * @author hewei
     */
    int batchInsert(@Param("list") List<Resource> list);

    List<Resource> selectList(ResourceDto resourceDto);

    /**
 * 根据资源编号查询资源
 *
 * @param resourceNo 资源编号
 * @return Resource 对象
 */
    @Results(id = "ResourceResult", value = {
        @Result(property = "id", column = "id"),
        @Result(property = "resourceNo", column = "resource_no"),
        // 添加其他字段映射，确保所有字段都能正确映射
    })
    @Select("SELECT * FROM sys_resource WHERE resource_no = #{resourceNo}")
    Resource selectByResourceNo(String resourceNo);

    /**
     * 删除当前资源
     * @param resourceNo
     */
    void deleteByResourceNo(String resourceNo);

    /**
     * 根据用户id查询资源
     */
    List<Resource> selectListByUserId(Long userId);

    /**
     * 根据用户id查询该用户下的菜单资源
     * @param userId
     * @return
     */
    List<MenuVo> findListByUserId(Long userId);
}